package com.wandon.ww.model.vo.common;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "响应结果的实体类")
public class Result<T> {

    @Schema(description = "响应码")
    private Integer code;

    @Schema(description = "响应信息")
    private String message;

    @Schema(description = "响应体")
    private T data;

    public Result<T> bulid(Integer code,String message,T data){
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public Result<T> bulid(T data,ResultCodeEnum resultCodeEnum){
        return new Result<>(resultCodeEnum.getCode(),resultCodeEnum.getMessage(),data);
    }
}
